home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17364 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: jpmorgan.com!usenet
  2. From: Oliver Peck <peck_oliver@jpmorgan.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Exceptions, shared libraries & SparcWorks
  5. Date: Mon, 15 Apr 1996 16:05:41 +0100
  6. Organization: JP Morgan
  7. Message-ID: <317265C5.167EB0E7@jpmorgan.com>
  8. NNTP-Posting-Host: gm-fitrades4.uk.jpmorgan.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (X11; I; SunOS 4.1.3_U1 sun4m)
  13.  
  14. I am using V4.0.1 of the SparcWorks C++ compiler on SunOS 4.1.3_U1.
  15.  
  16. I have an executable which calls a shared library which calls another
  17. shared library in the following manner:-
  18.  
  19. Executable
  20. ----------
  21.  
  22. try
  23.   {
  24.    pDerivedObject = new DerivedObject( params );
  25.    }
  26. catch ( const MyException & )
  27.    {
  28.     // Do something
  29.    }
  30.  
  31.  
  32. Shared library 1
  33. ----------------
  34.  
  35. DerivedObject::DerivedObject( PARAMS params ) throw( MyException )
  36.           
  37.                : Object( params )
  38.   {
  39.    try
  40.      {
  41.       Object object( different_params );
  42.  
  43.       // Use some stuff from object
  44.       }
  45.    catch( const MyException & )
  46.       {
  47.       // Do something
  48.       } 
  49.  
  50.    }
  51.  
  52. Shared library 2
  53. ----------------
  54.  
  55. Object::Object( PARAMS params ) throw( MyExeption )
  56.  
  57. {
  58.    // Do something  
  59.  
  60.    if ( error )
  61.      throw( MyException() );
  62.  
  63. }
  64.  
  65.  
  66. (Object is a base class of DerivedObject)
  67.  
  68. Strangely, if the object( different_params ) constructor throws, 
  69. this is only caught by the catch in the executable, completely missing
  70. the DerivedObject() catch. 
  71.  
  72. If I statically link the libraries with the executable, all works fine.
  73.  
  74. I have tried to understand the "documentation" in the compiler Library
  75. Reference Manual on shared libraries, but although I am using the -G
  76. option, I am not doing any of the __init_lib_, _init_foo_, __dummmy_foo
  77. stuff as I do not really understand it and cannot get it to work anyway.
  78.  
  79. Also, what is the .sa file for. It gets created but 1 do not use it at
  80. link or run time?
  81.  
  82. All suggestions gratefully received.
  83.  
  84. Regards
  85.  
  86. Oliver
  87.